package ltd.trackan.messagecenter.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ltd.trackan.messagecenter.common.ValueCommon;
import ltd.trackan.messagecenter.mapper.JdaccountMapper;
import ltd.trackan.messagecenter.model.coommon.RestBean;
import ltd.trackan.messagecenter.model.entity.JDAccount;
import ltd.trackan.messagecenter.service.JDAccountService;
import org.springframework.stereotype.Service;

/**
 * @author wxa
 * @description 针对表【jdaccount(京东账号表)】的数据库操作Service实现
 * @createDate 2025-03-11 11:07:46
 */
@Service
public class JDAccountServiceImpl extends ServiceImpl<JdaccountMapper, JDAccount>
        implements JDAccountService {
    
    @Override
    public RestBean<String> updateMapper() {
        try {
            ValueCommon.JD_ACCOUNT_MAPPER_ID.clear();
            ValueCommon.JD_ID_MAPPER_COMMENT.clear();
            this.baseMapper.selectList(null).forEach(JDAccount -> {
                ValueCommon.JD_ACCOUNT_MAPPER_ID.put(JDAccount.getPtPin(), JDAccount.getUId());
                ValueCommon.JD_ID_MAPPER_COMMENT.put(JDAccount.getUId(), JDAccount.getComment());
            });
            return RestBean.success();
        }catch (Exception e){
            return RestBean.failure(e.getMessage());
        }
    }
}




